Blockly.Blocks['string_length'] = {
    init: function() {
        this.appendValueInput('VALUE')
            .setCheck('String')
            .appendField('pi-top length of');
        this.setOutput(true, 'Number');
        this.setColour(160);
        this.setTooltip('Returns number of letters in the provided text.');
        this.setHelpUrl('http://www.w3schools.com/jsref/jsref_length_string.asp');
    }
};

var mathChangeJson = {
    "message0": "pi-top change %1 by %2",
    "args0": [
        {"type": "field_variable", "name": "VAR", "variable": "item", "variableTypes": [""]},
        {"type": "input_value", "name": "DELTA", "check": "Number"}
    ],
    "previousStatement": null,
    "nextStatement": null,
    "colour": 230
};
Blockly.Blocks['math_change'] = {
    init: function() {
        this.jsonInit(mathChangeJson);
        // Assign 'this' to a variable for use in the tooltip closure below.
        var thisBlock = this;
        this.setTooltip(function() {
            return 'Add a number to variable "%1".'.replace('%1',
                thisBlock.getFieldValue('VAR'));
        });
    }
};
var controls_repeat = {
    "type": "controls_repeat_ext",
    "message0": "pi-top repeat %1 times",
    "args0": [
        {"type": "input_value", "name": "TIMES", "check": "Number"}
    ],
    "message1": "do %1",
    "args1": [
        {"type": "input_statement", "name": "DO"}
    ],
    "previousStatement": null,
    "nextStatement": null,
    "colour": 120
};
Blockly.Blocks['controls_repeat_ext'] = {
    init: function() {
        this.jsonInit(controls_repeat);
    }
};
